Page({
  data:{
    car_detail:[],
    scanCodeMsg:""
  },
  onLoad:function(options){
    var carlist = wx.getStorageSync("carlist")
    console.log(carlist)
    var postId = options.id;
    var len = carlist.length;
    for(var i=0;i<len;i++){
      if(carlist[i].c_id == postId){
        this.setData({
          car_detail:carlist[i]
        })
      }
    }
  },
  saomatiche:function(){
    var that  = this;
    wx.scanCode({
      onlyFromCamera: true,
      success(res) {
       that.setData({
         scanCodeMsg:res.result
       });
        wx.request({
          url: 'https://www.hkzhaoscut.top/borrow',
          data:{
            c_id:that.data.scanCodeMsg
          },
          success:function(){
            wx.showToast({
              title: '提车成功',
              icon: 'success',
              duration: 2000
            });
          wx.request({
            url: 'https://www.hkzhaoscut.top/insertthefirsttime',
            data:{
              u_id :wx.getStorageSync("openid"),
              c_id : that.data.scanCodeMsg
            },
            success:function(){
              wx.redirectTo({
                url: '../../takecar/takecar',
              })
            },
            fail:function(){
              console.log("charu shibai le ")
            }
          })
           /*wx.redirectTo({
             url: '../../takecar/takecar',
           })*/
          },
          fail:function(){
            wx.redirectTo({
              url: '../msg_fail/msg_fail',
            })
            console.log("fail")
          }
        })
      
      }
    })
  },
  shoufeixiangqing:function(){
    wx.showModal({
      content: "收费详情如下：3分钟以内12块，超过3分钟的部分按3块/1分钟收费",
      showCancel: false,
      success: function (res) {
        if (res.confirm) {
          console.log('用户点击确定')
        }
      }
    });
  }
})